﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace WebMobie.Models.Entities
{
	public class Order
	{
		[ScaffoldColumn(false)]
		public int Id { get; set; }
		[Required]
		public String CustomerName { get; set; }
		public String CustomerPhone { get; set; }
		public int SellerId { get; set; }
		public virtual User Seller { get; set; }
		public int Status { get; set; }
		public decimal Total { get; set; }
		public ShippingInfo ShippingInfo { get; set; }
		public DateTime DateCreated { get; set; }
		public virtual ICollection<OrderDetail> OrderDetails { get; set; }

        public void autoGetTotal()
        {
            this.Total = 0;
            for (int i = 0; i < this.OrderDetails.Count; i++)
            {
                OrderDetail iDetail = this.OrderDetails.ElementAt(i);
                this.Total += iDetail.SubTotal;
            }

        }
	}
}